//
// Created by iris on 24-11-1.
//

#ifndef CVISITOR_H
#define CVISITOR_H

#include "AST/ASTBase.h"

#include "CBaseVisitor.h"
#include "misc/tools.h"


class ASTGenerator final : public CBaseVisitor {
public:
    std::any visitCompoundStatement(CParser::CompoundStatementContext *ctx) override;

    std::any visitFunctionDefinition(CParser::FunctionDefinitionContext *ctx) override;

    std::any visitCompilationUnit(CParser::CompilationUnitContext *ctx) override;

    std::any visitJumpStatement(CParser::JumpStatementContext *ctx) override;

    std::any visitInitializer(CParser::InitializerContext *ctx) override;

    std::any visitExpressionStatement(CParser::ExpressionStatementContext *ctx) override;

    std::any visitTranslationUnit(CParser::TranslationUnitContext *ctx) override;

    std::any visitExternalDeclaration(CParser::ExternalDeclarationContext *ctx) override;

    std::any visitBlockItem(CParser::BlockItemContext *ctx) override;

    std::any visitPrimaryExpression(CParser::PrimaryExpressionContext *ctx) override;

    std::any visitPostfixExpression(CParser::PostfixExpressionContext *ctx) override;

    std::any visitUnaryExpression(CParser::UnaryExpressionContext *ctx) override;

    std::any visitCastExpression(CParser::CastExpressionContext *ctx) override;

    std::any visitMultiplicativeExpression(CParser::MultiplicativeExpressionContext *ctx) override;

    std::any visitAdditiveExpression(CParser::AdditiveExpressionContext *ctx) override;

    std::any visitShiftExpression(CParser::ShiftExpressionContext *ctx) override;

    std::any visitRelationalExpression(CParser::RelationalExpressionContext *ctx) override;

    std::any visitEqualityExpression(CParser::EqualityExpressionContext *ctx) override;

    std::any visitAndExpression(CParser::AndExpressionContext *ctx) override;

    std::any visitExclusiveOrExpression(CParser::ExclusiveOrExpressionContext *ctx) override;

    std::any visitInclusiveOrExpression(CParser::InclusiveOrExpressionContext *ctx) override;

    std::any visitLogicalAndExpression(CParser::LogicalAndExpressionContext *ctx) override;

    std::any visitLogicalOrExpression(CParser::LogicalOrExpressionContext *ctx) override;

    std::any visitConditionalExpression(CParser::ConditionalExpressionContext *ctx) override;

    std::any visitAssignmentExpression(CParser::AssignmentExpressionContext *ctx) override;

    std::any visitDeclaration(CParser::DeclarationContext *ctx) override;

    std::any visitSelectionStatement(CParser::SelectionStatementContext *ctx) override;

    std::any visitStatement(CParser::StatementContext *ctx) override;

    std::any visitIterationStatement(CParser::IterationStatementContext *ctx) override;

    struct Helper {
        static ast::type::ASTType getType(CParser::TypeSpecifierContext *ctx);

        static ast::ASTOperator getAssignOperator(CParser::AssignmentOperatorContext *ctx);
    };
};

void run_antlr(const std::string &src);
#endif //CVISITOR_H
